package cn.lger.controller.advice;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * Code that Changed the World
 *
 * @author Pro
 * @date 2018-06-30.
 */
@RestControllerAdvice(annotations = RestController.class)
public class RestControllerExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Map handler(Exception e){
        Map<String, String> map = new HashMap<>(2);
        map.put("msg", e.getMessage());
        map.put("success", Boolean.FALSE.toString());
        return map;
    }

}
